import os

def create_knowledge_base():
    """创建知识库目录结构"""
    
    # 基础目录结构
    kb_structure = {
        "docs/knowledge_base": {
            "architecture": {  # 架构设计
                "system_design.md",        # 系统设计文档
                "data_flow.md",           # 数据流说明
                "component_design.md"      # 组件设计文档
            },
            "development": {  # 开发指南
                "setup_guide.md",         # 环境搭建指南
                "coding_standards.md",     # 编码规范
                "git_workflow.md"         # Git工作流程
            },
            "features": {  # 功能模块
                "translation": {
                    "overview.md",         # 翻译功能概述
                    "implementation.md",    # 实现细节
                    "api_reference.md"     # API参考
                },
                "language_detection": {
                    "overview.md",
                    "implementation.md",
                    "api_reference.md"
                }
            },
            "database": {  # 数据库
                "schema.md",              # 数据库架构
                "queries.md",             # 常用查询
                "optimization.md"         # 优化指南
            },
            "deployment": {  # 部署
                "deployment_guide.md",     # 部署指南
                "monitoring.md",          # 监控方案
                "maintenance.md"          # 维护指南
            },
            "examples": {  # 示例代码
                "translation_examples.md",
                "api_usage.md",
                "integration_examples.md"
            }
        }
    }
    
    # 创建目录和文件
    for path, contents in kb_structure.items():
        if isinstance(contents, dict):
            os.makedirs(path, exist_ok=True)
            for subpath, subcontents in contents.items():
                full_subpath = os.path.join(path, subpath)
                if isinstance(subcontents, dict):
                    os.makedirs(full_subpath, exist_ok=True)
                    for filename in subcontents:
                        with open(os.path.join(full_subpath, filename), 'w', encoding='utf-8') as f:
                            f.write(f"# {filename[:-3].replace('_', ' ').title()}\n\n")
                else:
                    with open(full_subpath, 'w', encoding='utf-8') as f:
                        f.write(f"# {subpath[:-3].replace('_', ' ').title()}\n\n")

if __name__ == "__main__":
    create_knowledge_base()
    print("Knowledge base structure created successfully!") 